package com.softserveinc.interactive_board.validators.form;

import java.util.Date;
import java.util.List;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.format.annotation.DateTimeFormat;

import com.softserveinc.interactive_board.domain.Presentation;
import com.softserveinc.interactive_board.domain.PresentationStatus;
import com.softserveinc.interactive_board.domain.User;
import com.softserveinc.interactive_board.domain.Slide;

public class AddPresentationForm {

	public AddPresentationForm(Long id, String title, int status,
			String description, Long userId, Date date, List<Slide> slides) {
		this.id = id;
		this.name = title;
		this.statusId = status;
		this.description = description;
		this.userId = userId;
		this.date = date.toString();
		this.slides = slides;
	}

	public AddPresentationForm() {
		this(new Long(1), "untitled", PresentationStatus.ID_IN_CREATING,
				"describe this presentation", new Long(0), new Date(), null);
	}

	public AddPresentationForm(final Presentation presentation) {
		this(presentation.getId(), presentation.getName(), presentation
				.getStatus().getId(), presentation.getDescription(),
				presentation.getUser().getId(), presentation.getDate(),
				presentation.getSlides());
	}

	public Presentation getPresentation() {
		return new Presentation(this.id, this.name, new PresentationStatus(
				this.statusId), this.description, new User(this.userId),
				new Date(), this.slides);
	}

	private Long id;

	@NotEmpty
	@Size(max = Presentation.COLUMNS_MAX_LENGTH)
	private String name;

	@Min(PresentationStatus.ID_MIN_VALUE)
	@Max(PresentationStatus.ID_MAX_VALUE)
	private int statusId;

	@Size(max = Presentation.DESCRIPTION_COLUMN_MAX_LENGTH)
	private String description;

	@Min(1)
	private Long userId;

	@DateTimeFormat(pattern = "dd/MM/YY")
	private String date;

	private List<Slide> slides;

	public List<Slide> getSlides() {
		return slides;
	}

	public void setSlides(List<Slide> slides) {
		this.slides = slides;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public int getStatusId() {
		return statusId;
	}

	public void setStatusId(int statusId) {
		this.statusId = statusId;
	}

	public String getName() {
		return name;
	}

	public void setName(String title) {
		this.name = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

}
